package de.neunvolle.android.backuprestore;

import java.util.ArrayList;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import de.neunvolle.android.backuprestore.data.MemberData;

public class MembersActivity extends ListActivity {
	
	ListView lv;
	EditText et;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.members);

		lv = getListView();
		et = (EditText) findViewById(R.id.editText_add_member);
		
		ArrayList<MemberData> a = new ArrayList<MemberData>();
		int i = 0;
		MemberData m1 = new MemberData();
		m1.setId(i++);
		m1.setName("A");
		a.add(m1);
		MemberData m2 = new MemberData();
		m2.setId(i++);
		m2.setName("B");
		a.add(m2);

		Log.w("me", getListView().toString());
		Log.w("me", getListView().getId()+"");
		
		ListAdapter adapter = new ArrayAdapter<MemberData>(this, android.R.layout.simple_list_item_1, a);  //listview id passt nicht
		//TODO: list item activated? selectable?
		//TODO: button logo statt text, ähnlich wie in contacts?
		
		setListAdapter(adapter);
	}
	
	//TODO: register context menu with edit, delete option
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		
		MemberData selected = (MemberData) l.getItemAtPosition(position);
		Log.w("me", selected + " wurde ausgewählt");
		
		//TODO: switch to MemberDetailActivity?
	}
}
